package com.jt.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.fasterxml.jackson.databind.util.JSONPObject;
import com.jt.pojo.SysResult;
import com.jt.pojo.User;
import com.jt.service.DubboUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jt.service.UserService;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RequestMapping("/user")
@RestController
public class UserController {
	
	@Autowired
	private UserService userService;
	@Reference
	private DubboUserService dubboUserService;

	@RequestMapping("/check/{param}/{type}")
	public JSONPObject checkUser(@PathVariable String param, @PathVariable Integer type, String callback){
		boolean flag=userService.findAll(param,type);
		SysResult sysResult=SysResult.success(flag);
		return new JSONPObject(callback, sysResult);


	}
	@RequestMapping("/findUserList")
	public List<User> findUserList(){
		return userService.findUserList();
	}
	
	@RequestMapping("/doRegister")
	public SysResult doRegister(User user){
		dubboUserService.doRegister(user);
		return SysResult.success();
	}

	public SysResult doLogin(User user, HttpServletResponse){
		Cookie cookie=new Cookie(User, );
		cookie.getDomain("");

	}
	
	
	
}
